/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q0083.java
 * @Author : WangRuoyu
 * @Date 2022/12/26 16:15
 */

package leetcode;

import util.LinkList;
import util.ListNode;

public class Q0083 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) return head;
        ListNode p = head;
        while (p.next != null) {
            if (p.val == p.next.val) p.next = p.next.next;
            else p = p.next;
        }
        return head;
    }

    public static void main(String[] args) {
        Q0083 sl = new Q0083();
        ListNode head = LinkList.createList(new int[]{1, 1, 2, 3, 3});
        ListNode p = sl.deleteDuplicates(head);
        LinkList.printList(p);
    }
}
